<?php $this->load->module('hm/index/header', $common); ?>
<link rel="stylesheet" href="<?php echo URLPRE; ?>static/hm/css/order_detail.css" type="text/css">
<script type="text/javascript" src="<?php echo URLPRE; ?>static/template/default/mobile/js/layer/layer.js"></script>

<!-- 日历插件-->
<link rel="stylesheet" type="text/css"
      href="<?php echo URLPRE; ?>static/template/<?php echo MOBILE_TEMPLATE_NAME ?>/mobile/mobiscroll/css/mobiscroll.css"/>


<script type="text/javascript"
        src="<?php echo URLPRE; ?>static/template/<?php echo MOBILE_TEMPLATE_NAME ?>/mobile/mobiscroll/js/mobiscroll.js"></script>

<script type="text/javascript">
    var urlD = '<?php echo site_url('hm/order/room_repertory');?>';

    $(function () {
        //  日历切换


        $('#start_date').change(function () {

            var date = $(this).val();
            var month = '';
            var day = '';
            d = new Date(date);
            d = +d + 1000 * 60 * 60 * 24;
            d = new Date(d);

            month = d.getMonth();

            day = d.getDate();

            if ((d.getMonth() + 1).toString().length == 2) {
                month = (d.getMonth() + 1);
            } else {
                month = '0' + (d.getMonth() + 1);
            }

            if (d.getDate().toString().length == 2) {
                day = d.getDate();
            } else {
                day = '0' + (d.getDate());
            }

            var newdate = d.getFullYear() + "-" + month + "-" + day;


            $('#end_date').val(newdate);
            $('#end_date').mobiscroll().date({
                theme: 'mobiscroll',
                lang: 'zh',
                display: 'center',
                dateFormat: 'yyyy-mm-dd',
                min: new Date(d.getFullYear(), d.getMonth(), d.getDate()),
                max: new Date(2016, 12, 31)
            });

            var end = $('#end_date').val();
            var df_date = $('#end_date').data('default');

            if(end !== df_date)
            {
                var url = urlD+'?start='+date+'&end='+end ;
                layer.msg('加载中...');
                window.location.href = url;
            }
        })


        $('#end_date').change(function () {

            var start = $('#start_date').val();
            var end = $('#end_date').val();
            var url = urlD+'?start='+start+'&end='+end ;
            layer.msg('加载中...');
            window.location.href = url;
        })


        $('#start_date').mobiscroll().date({
            theme: 'mobiscroll',
            lang: 'zh',
            display: 'center',
            dateFormat: 'yyyy-mm-dd',
            min: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()),
            max: new Date(2016, 12, 31)
        });

        $('#end_date').mobiscroll().date({
            theme: 'mobiscroll',
            lang: 'zh',
            display: 'center',
            dateFormat: 'yyyy-mm-dd',
            min: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1),
            max: new Date(2016, 12, 31)
        });


    })
</script>
<div class="page active">
    <header class="list-head J_header">
        <a class="back J_back" href="javascript:history.back();">首页</a>
        <div class="addr J_addr" style="visibility: hidden">

        </div>
    </header>

    <div class="repertory-list">

        <div class="tip shopdet">
            <p>
                <span class="in-input-span">开始 :</span>
                <input type="text" class="in-input mbsc-comp" id="start_date" value="<?php echo  $start;?>" placeholder="请选择开始日期" name="start_date" readonly>

                <span class="in-input-span">结束 :</span>
                <input type="text" class="in-input mbsc-comp" id="end_date" data-default="<?php echo $end;?>" value="<?php echo  $end;?>" placeholder="请选择结束日期" name="end_date" readonly>

            </p>
        </div>

        <?php if ($room_list): ?>
            <?php foreach ($room_list as $key => $item): ?>

                <a  <?php if (in_array($item['id'], $lock_room)): ?>
                     href="javascript:;"
                <?php else: ?>
                     href="<?php echo site_url('hm/order/add') ;?>"
                <?php endif; ?>
                   >
                    <div class="rep-wrap <?php if (in_array($item['id'], $lock_room)): ?> full-tag<?php endif; ?>">
                        <div class="shopname">
                            <span class="tit new-tit"><?php echo $item['name']; ?></span>
                            <?php if (in_array($item['id'], $lock_room)): ?>
                                <div class="icon">
                                    <span class="brand">满房</span></div>
                            <?php else: ?>
                                <div class="icon open-icon">
                                    <span class="open">可预定</span></div>
                            <?php endif; ?>
                        </div>
                        <div class="info">
                            <span class="monthsold"><?php if (!empty($lock_key_date[$item['id']])): ?>
                                    <?php echo implode(',', $lock_key_date[$item['id']]); ?>

                                <?php endif; ?></span>
                        </div>

                        <?php if ($item['contact_list']): ?>
                            <div class="intro">
                                    <span class="minprice">
                                <span class="price-orange"><?php echo $item['contact_list'][0]['name']; ?></span>
                            </span>
                                    <span class="deliveryprice"><?php echo $item['contact_list'][0]['phone_num']; ?>
                            </span>

                            </div>
                        <?php endif; ?>


                    </div>
                </a>


            <?php endforeach; ?>
        <?php endif; ?>



    </div>

    <?php $this->load->module('hm/index/footer',$common); ?>
